using System;
using System.Collections;
using System.Xml;
using System.Xml.Serialization;

namespace TextParsing.GraphStructure
{
	public class ParsedFiles
	{
		private ArrayList m_parsedFileNames;

		public ParsedFiles() { m_parsedFileNames = new ArrayList(); }

		[XmlArrayItem("file",typeof(string),IsNullable = true)]
		[XmlArray("parsed_files")]
		public IList Files
		{
			get { return m_parsedFileNames; }
		}

		public void XmlWrite(string path)
		{
			XmlTextWriter writer = null;
			
			try
			{
				writer = new XmlTextWriter(path,System.Text.Encoding.ASCII);
				writer.Formatting = System.Xml.Formatting.Indented;
				writer.WriteStartDocument();

				writer.WriteStartElement("parsed_files");

				foreach(string filename in m_parsedFileNames)
				{
					writer.WriteElementString("file",filename);
				}

				writer.WriteEndElement();
				writer.WriteEndDocument();
			}
			catch(Exception ex)
			{
				throw ex;
			}
			finally
			{
				writer.Close();
			}
		}
	}
}
